import { defineConfig, loadEnv } from "@rsbuild/core";
import { pluginVue2 } from "@rsbuild/plugin-vue2";
import { pluginSass } from "@rsbuild/plugin-sass";

const { publicVars } = loadEnv({ prefixes: ["VUE_APP_"] });

let proxy = {};

export default defineConfig(({ env }) => {
  return {
    plugins: [
      pluginVue2(),
      pluginSass({
        sassLoaderOptions: {
          silenceDeprecations: ["import"],
        },
      }),
    ],
    source: {
      // 指定入口文件
      entry: {
        index: "./src/main.js",
      },
      define: {
        ...publicVars,
      },
      alias: {
        "@": "./src/",
      },
    },
    server: {
      port: 7374,
      proxy: {
        ...proxy,
      },
    },
    html: {
      template: "./public/index-rsbuild.html",
    },
  };
});
